<!DOCTYPE html>
<html lang="zh_CN" class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>日志管理</title>
    <header th:replace="header::html"></header>
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">登录</a>
        <a>
          <cite>日志列表</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>

<div class="x-body">
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body" permission="sys:log:query">
                        <form class="layui-form layui-col-space5">
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="username" placeholder="请输入用户名" autocomplete="off"
                                       class="layui-input">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" lay-submit="" lay-filter="search"><i
                                        class="layui-icon">&#xe615;</i></button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-body ">
                        <table class="layui-hide" id="table" lay-filter="member"></table>
                    </div>
                    <div class="layui-card-body ">
                        <script type="text/html" id="toolbarDemo">
                            <div class="layui-btn-container">
                            </div>
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

</body>
</html>
<script type="text/javascript">
    layui.use(['table', 'form'], function () {
        var table = layui.table,
            form = layui.form;
        var tableIns = table.render({
            elem: '#table'
            , url: '/log/list' //数据接口
            , page: true //开启分页
            , toolbar: '#toolbarDemo'
            , where: {
                "type": 0,
                "typeMenu": 0
            }
            , response: {
                dataName: "datas" //规定数据列表的字段名称
            }
            , cols: [
                [
                    , {field: 'id', title: 'ID', sort: true, width: 80, align: "center"}
                    , {field: 'username', title: '用户名'}
                    , {field: 'operation', title: '操作'}
                    , {
                    field: 'type', title: '类型', templet: function (d) {
                        if (d.type === 0) {
                            return '登录';
                        } else if (d.type === 1) {
                            return '菜单';
                        } else if (d.type === 2) {
                            return '按钮';
                        }
                    }
                }
                    , {field: 'borderName', title: '浏览器'}
                    , {field: 'osName', title: '操作设备'}
                    , {field: 'ip', title: 'IP地址'}
                    , {field: 'time', title: '操作时间'}
                ]
            ],
            done: function () {
                checkPermission();
            }
        });

        form.on('submit(search)', function (data) {
            var username = data.field.username;
            tableIns.reload({
                url: "/log/findLogByUsername",
                where: {
                    "username": username,
                    "type": 0
                },
                page: {curr: 1}
            })
            return false;
        });
        checkPermission();
    });
</script>
